
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.tss.util.*"%>
<%@page import="com.store.*"%>
<%@page import="com.jedi.*"%>
<%@page import="java.util.*"%>
<%@include file="../global_var.jsp"%>
<%@include file="../check_login.jsp"%>
<%@page import="java.text.*"%>
<%
String edate = new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime());
Calendar calen = Calendar.getInstance();
calen.setTime(TSSDate.parseDate(edate));
calen.add(Calendar.YEAR, -1);
String bdate = new SimpleDateFormat("yyyy-MM-dd").format(calen.getTime());
User just_user = (User)session.getAttribute("LoginUser");
String power_enable_id = "10701";
if (!just_user.hasPower(power_enable_id)) {
	out.println(strNoPowerInfo); 
	return;
}
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
CompanyMgr companyMgr = new CompanyMgr();

List list = null;
String begin_date    = ParamUtils.getParameter(request,"begin_date",bdate);
String end_date      = ParamUtils.getParameter(request,"end_date",edate);
String comname   = ParamUtils.getParameter(request,"comname","");
%>
<html>
<head>
    <base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<link href="style/main.css" rel="stylesheet" type="text/css">
<script language="javascript" src="js/common.js"></script>
<script language="javascript">
function clk_contract_show(id) {
	right_menu_clk("company_show.jsp?comid=" + id);
}
function clk_chanage(url){
	location.href=url;

}
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
	 <td >
		<form name="pageForm" method="post">
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td height="100" valign="top" align="center" style="padding-top:12px;padding-bottom:10px;">
								
					<table width="98%" border="0" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF">
					<tr bgcolor="#D7D7DB">
						<td height="24" style="padding-left:10px;" >
					

				登记日期：  从 <span id="htmlBeginTime">&nbsp;</span> &nbsp; 至 &nbsp; <span id="htmlEndTime" >&nbsp;</span>
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;	<input type="submit" class="inputButton" value="确定" >
				</td>
					<td align="center" width="11%">
				
			<span onclick="right_menu_clk('company_add.jsp');" style="cursor:hand;font-size:12px;text-de--ation: underline;">添加厂商</span>
				    </td>
				  </tr>
			<tr bgcolor="#FFFFFF">
											<td height="15" style="padding-left:10px;" colspan="4">
											</td></tr>
									</table>
									<table width="98%" border="0" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF">
					<tr align="center" bgcolor="#858585">
						
						<td width="15%"  height="24"><font color="#FFFFFF">厂商名称</font></td>
						
						<td width="10%" height="24"><font color="#FFFFFF">厂商电话</font></td>
						  <td width="10%"><font color="#FFFFFF">登记日期</font></td>
						    <td width="20%"><font color="#FFFFFF">厂商地址</font></td>
						<td width="7%"><font color="#FFFFFF">操作</font></td>
						
					</tr>
					<%
              String otherSQL = "";
              if (!comname.trim().equals("")) otherSQL += " and comname like '%" + comname.trim() + "%'";
	              if (!begin_date.trim().equals("")) otherSQL += " and substring(createtime for 10) >= '" + begin_date.trim() + "'";
	              if (!end_date.trim().equals("")) otherSQL += " and substring(createtime for 10) <= '" + end_date.trim() + "'";
        
              String orderField = "createtime desc";
              int pageSize = 10;
              int pageno=1;
               String page2=request.getParameter("mgh");
            	
              	
              		if(page2==null||page2==""){
              				pageno=1;
              				}
              			else{
              					pageno=Integer.parseInt(page2);
              				}
              int pageNo = ParamUtils.getIntParameter(request,"page",pageno);
              	             String pageno1 = String.valueOf(pageNo); 
							session.setAttribute("pageno1",pageno1);
              list = companyMgr.get(otherSQL,orderField,pageNo,pageSize);
              int total = companyMgr.getTotal(); 
              boolean b=(total % pageSize ==0);
              int pageCount=b?(total/pageSize):(total/pageSize +1);
              if(pageNo>pageCount){
              	pageNo=pageCount;
              }
              if (list != null && list.size() > 0) {
              	String bgColor[] = {"#EDEDF0","#D7D7DB"};
              	for(int i=0;i<list.size();i++) {
              		Company item = (Company)list.get(i);
              		Calendar cal = Calendar.getInstance();
              		cal.setTime(TSSDate.parseDate(item.getCreatetime()));
              %>
					<tr align="center" bgcolor="<%=bgColor[i%2]%>">
						<td height="24"><a
							href="system_mgt/company_detail.jsp?comid=<%=item.getComid()%>"><%=item.getComnam()%></a>
						</td>
						<td><%=item.getComtel()%></td>
						<td><%=item.getCreatetime() %></td>
						<td><%=item.getComaddress()%></td>
						<td><span onclick="clk_contract_show('<%=item.getComid()%>');" style="cursor:hand;text-decoration: underline;">修改</span></td>
					</tr>
					<%}%>
				</table>
				<table width="100%" border="0" cellpadding="0" cellspacing="0"
					background="images/page_img/page_bk.gif">
					
					<tr height="32" align="center" valign="bottom">
						<td width="5%"><img src="images/page_img/page_tag_01.gif"> 
							</td>
						<td height="35" align="right" style="padding-right:10px;"
							valign="bottom" id="pannelPageInfo">&nbsp;</td>
					</tr>
				</table>
				<script language="javascript">
            pannelPageInfo.innerHTML = getPageInfo(<%=total%>,<%=pageSize%>,<%=pageNo%>,5,'images/page_img','pageForm');
            </script> <%}else{%>
		</table>
		<table width="95%" border="0" cellpadding="4" cellspacing="1"
			bgcolor="#FFFFFF">
			<tr>
				<td height="60" align="center">请选择条件查询项目信息!</td>
			</tr>
		</table>
		<%}%>
		</form>
		</td>
		</tr>
		</table>
		
<script language="javascript">
	htmlBeginTime.innerHTML = showCalenderInput("begin_date","pageForm","<%=begin_date%>",1);
	htmlEndTime.innerHTML = showCalenderInput("end_date","pageForm","<%=end_date%>",1);
</script>
	
	</body>
</html>
